package org.example.nebula.common.config;

import com.vesoft.nebula.client.graph.net.NebulaPool;
import com.vesoft.nebula.client.graph.net.Session;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * @author: jszhang
 * @date: 2023/2/13-10:25
 */
@Slf4j
@Component
public class NebulaSession {

    @Autowired
    NebulaPool nebulaPool;

    @Autowired
    NebulaGraphProperties nebulaGraphProperties;

    @Bean
    public Session session() throws Exception {

        log.info(nebulaGraphProperties.toString());
        return nebulaPool.getSession(nebulaGraphProperties.getUserName(),nebulaGraphProperties.getPassword(),true);
    }

}
